package com.ysd.dao.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import com.ysd.entity.XiangQing;
import com.ysd.util.DBManager;

public class TuiJianZXDaoImpl {
	public List<XiangQing> getTJXiangQ(){//什么是有看参数呢?一般看sql语句有条件没有
		List<XiangQing> xqList = new ArrayList<XiangQing>();
		
		Connection conn = DBManager.getConnection();
		Statement st = null;
		ResultSet rs = null;
		
		try {
			st = conn.createStatement();
			rs = st.executeQuery("SELECT * from zxxiangqing ORDER BY RAND() LIMIT 3");
			while (rs.next()) {
				int pId = rs.getInt("zXXiangQingID");
				String pName = rs.getString("zXBiaoTi");
				String imgs = rs.getString("zXNeiRong");
				String zxnr=rs.getString("zXBTNeiRong");
				XiangQing xiangqing = new XiangQing(pId, pName, imgs, zxnr, pId);
				xqList.add(xiangqing);
			}return xqList;
		} catch (SQLException e) {
			e.printStackTrace();
			return null;
		}finally {
			DBManager.closeAll(conn, st, rs);
		}
	}
}
